package com.xizi.work;

import com.rabbitmq.client.Channel;
import com.xizi.utils.RabbitUtils;

import java.util.Scanner;

public class Task01 {
  private static final String QUEUE_NAME = "work";

  public static void main(String[] args) {
   try(Channel channel= RabbitUtils.getConnection().createChannel();) {
        channel.queueDeclare(QUEUE_NAME,true,false,false,null);
        //从控制台当中接受信息
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
           String message = scanner.next();
           channel.basicPublish("",QUEUE_NAME,null,message.getBytes());
           System.out.println("发送消息完成:"+message);
        }
   }catch (Exception e){
        e.printStackTrace();
   }
  }
}